# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator  import SparkSqlOperator
from jms.dm.dm_dense_deliver_details_dt import jms_dm__dm_dense_deliver_details_dt

jms_dm__dm_dense_deliver_daily_summary_dt = SparkSqlOperator(
    task_id='jms_dm__dm_dense_deliver_daily_summary_dt',
    email=['jarl.huang@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    name='jms_dm__dm_dense_deliver_daily_summary_dt_{{ execution_date | date_add(1) | cst_ds }}',
    email_on_retry=True,
    retries=0,
    sql='jms/dm/dm_dense_deliver_daily_summary_dt/execute.sql',
    yarn_queue='pro',
    driver_memory='3G' , 
    driver_cores=2 , 
    executor_memory='2G' , 
    executor_cores=2 , 
    pool_slots=2,
    pool='unlimited_pool',
    num_executors=2 , 
    conf={
        'spark.executor.memoryOverhead'             : '2G' , 
          'spark.dynamicAllocation.enabled': 'true',
          'spark.shuffle.service.enabled': 'true',
        'spark.dynamicAllocation.maxExecutors'             : 2 , 
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',
          'spark.dynamicallocation.enabled': 'true',
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 120,
          'spark.sql.shuffle.partitions': 200
          },
    hiveconf={'hive.exec.dynamic.partition': 'true',
              'hive.exec.dynamic.partition.mode': 'nonstrict',
              'hive.exec.max.dynamic.partitions.pernode': 5000,
              'hive.exec.max.dynamic.partitions': 30000
              },
    execution_timeout=timedelta(minutes=30),
    priority_weight=20,
)

jms_dm__dm_dense_deliver_daily_summary_dt << [
    jms_dm__dm_dense_deliver_details_dt
]
